package cm.hua.yuan.common.utils;

import android.app.Application;
import android.content.Context;
import android.support.annotation.NonNull;

/**
 * @Author: richsjeson.
 * @Description: TODO()
 * @Date:Created in 2018/12/13 上午12:43.
 * @Modified By:
 */
public class AppContextManager {

    private Context mContext;

    private Application mApplication;

    private static AppContextManager mContextManager;

    public static AppContextManager getInstance(){

        synchronized (AppContextManager.class){

            if(mContextManager==null){
                synchronized (AppContextManager.class){
                    mContextManager=new AppContextManager();
                }
            }
        }
        return mContextManager;
    }


    public void init(@NonNull Context pContext, @NonNull Application pApplication){

        this.mContext=pContext;
        this.mApplication=pApplication;
    }

    public Context getContext(){
        return this.mContext;
    }


    public Application getApplication(){
        return this.mApplication;
    }


    public void relase(){
        mContext=null;
        mContextManager=null;
        mApplication=null;
    }
}
